package com.itheima.homework16;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

public class Demo1 {
    //反射越过编译期泛型检查
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        ArrayList<Integer> list=new ArrayList<>();
        Class clazz = ArrayList.class;
        Method method = clazz.getMethod("add", Object.class);
        method.invoke(list,"1000");
        method.invoke(list,100);
        method.invoke(list,123);
        method.invoke(list,'a');
        for (Object obj: list) {
            System.out.println(obj);

        }

    }
}
